<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic"
	prefix="logic"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"
	prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html"
	prefix="html"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://displaytag.sf.net/el" prefix="display-el"%>
<%@ taglib uri="ford-arg/tags" prefix="ft"%>

<script language="javascript">

	function findEconomicValue() {
		document.EconomicValueForm.action = "EconomicValuesActionFind.do";
		document.EconomicValueForm.section.value = "find";
		document.EconomicValueForm.validateSubmit.value="";
		document.EconomicValueForm.submit();
	}

	function editEconomicValue(obj) {
		document.EconomicValueForm.action = "EconomicValuesActionEdit.do";
		document.EconomicValueForm.operation.value = "createUpdate";
		document.EconomicValueForm.section.value = "edit";
		document.EconomicValueForm.numberEconomicValue.value=obj;
	}
	function newEconomicValue() {
		document.EconomicValueForm.action = "EconomicValuesActionNewRegister.do";
		document.EconomicValueForm.operation.value = "createUpdate";
		document.EconomicValueForm.section.value = "new";
		
	}
	
	function createUpdateEconomic() {
		document.EconomicValueForm.action = "EconomicValuesActionCreateUpdate.do";
		document.EconomicValueForm.validateSubmit.value="submit";
	}
	
	function deleteEconomicValue(obj) {
		if (confirm('<bean:message key="economicValue.confirmDelete" />')) {
			document.EconomicValueForm.action = "EconomicValuesActionDelete.do";
			document.EconomicValueForm.numberEconomicValue.value=obj;
			document.EconomicValueForm.validateSubmit.value="";
		}else{
			return false;
		}
	}
	
	function RejectEconomicValue(obj) {
			document.EconomicValueForm.action = "EconomicValuesActionReject.do";
			document.EconomicValueForm.numberEconomicValue.value=obj;
	}
	
	function cancelEconomic(){
		document.EconomicValueForm.action = "EconomicValuesActionClear.do";
		document.EconomicValueForm.validateSubmit.value="cancel";
		document.EconomicValueForm.section="false";
		document.EconomicValueForm.validateSubmit.value="cancel";
	}
	
	function approveEconomicValueFromList(){
		document.EconomicValueForm.action = "EconomicValuesActionApprove.do";
	}			
	function selectDesc(){
	document.getElementById("codeFind").value = "";

	}
	function selectCode(){
	document.getElementById("descFind").value = "";

	}
	
</script>

<table>
	<tr>
		<td colspan="2">
		<h2><bean:message key="economicValues.label.title" /></h2>
		</td>
	</tr>
</table>
<br />
<html:form action="/EconomicValuesActionFind">
	<html:hidden property="section" />
	<html:hidden property="operation" />
	<html:hidden property="numberEconomicValue" />
	<html:hidden property="validateSubmit" />	
	<%-- Mantiene el numero de pagina despues del submit --%>
	
	<bean:define id="codeTitle">
		<bean:message key="economicIndexDef.label.code" />
	</bean:define>
	<bean:define id="descriptionTitle">
		<bean:message key="economicIndexDef.label.description" />
	</bean:define>
	<bean:define id="sourceTitle">
		<bean:message key="economicIndexDef.label.source" />
	</bean:define>
	<bean:define id="unidadMonedaTitle">
		<bean:message key="economicIndexDef.label.currency" />
	</bean:define>
	<bean:define id="approvalTitle">
		<bean:message key="economicIndex.label.tableHeader.approval" />
	</bean:define>
	<bean:define id="actionsTitle">
		<bean:message key="economicIndex.label.tableHeader.actions" />
	</bean:define>
	<bean:define id="proposalRegistration">
		<bean:message key="economicValue.label.tableHeader.registration" />
	</bean:define>
	<bean:define id="porcVariacion">
		<bean:message key="economicValue.label.tableHeader.variacion" />
	</bean:define>
	<bean:define id="poriorV">
		<bean:message key="economicValue.label.tableHeader.priorV" />
	</bean:define>
	<bean:define id="valA">
		<bean:message key="economicValue.label.tableHeader.valA" />
	</bean:define>
	<bean:define id="poriorD">
		<bean:message key="economicValue.label.tableHeader.priorD" />
	</bean:define>
	<bean:define id="poriorVE">
		<bean:message key="economicValue.label.tableHeader.valorEstimado" />
	</bean:define>


	<%-- Panel de busqueda compartida --%>
	<table>
		<tr>
			<td class="text_blue_bold align_left" colspan="100%"><bean:message
				key="costStructure.item.label.filter" /></td>
		</tr>
		<tr>
			<td class="text_blue_bold align_left"><bean:message
				key="economicSource" /></td>
			<td class="align_left"><html:select property="sourcFind">
				<html:option value="-1" key="label.allOption" />
				<html:options collection="economicSources"
					property="eese02EconsourceNumberK"
					labelProperty="eese02EconsourceNameN" />
			</html:select> &nbsp; <bean:message key="economicValue.label.modoFA" /> 
			<html:select	property="typeFind">
				<html:options collection="economicsTypes" property="value"
						labelProperty="label" />
			</html:select>
			 &nbsp;</td>
		</tr>
		<tr>
			<td class="text_blue_bold align_left"><bean:message
				key="economicIndexDef.label.code" /></td>
			<td class="align_left"><html:text property="codeFind"
				maxlength="8" onfocus="selectCode();" /></td>

		</tr>
		<tr>
			<td class="text_blue_bold align_left"><bean:message
				key="costStructure.item.label.name" /></td>

			<td class="align_left"><html:text property="descFind"
				maxlength="25" onfocus="selectDesc();" />&nbsp; <html:select
				property="filterEstatus">
				<html:option value="todos" key="economicValue.label.option.todos" />
				<html:option value="aprobados"
					key="economicValue.label.option.aprobados" />
				<html:option value="registrados"
					key="economicValue.label.option.registrados" />
				<html:option value="noRegistrados"
					key="economicValue.label.option.noRegistrados" />
			</html:select></td>
		</tr>
		<tr>
			<td class="text_blue_bold align_left"><bean:message
				key="economicValue.label.period" /></td>
			<td class="text_blue_bold align_left">
				<bean:message key="label.year"/>:
				<html:text property="efectYear" size="5" maxlength="4"></html:text>
				<html:select property="efectMonth">
				<html:options collection="months" property="value"
					labelProperty="label" />

				</html:select> &nbsp; <html:button property="find" styleClass="button"
				onclick="findEconomicValue();">
				<bean:message key="label.find" />
			</html:button></td>
		</tr>
		<tr>
		</tr>
	</table>

	<!-- Fin de panel de busqueda -->

	<br />
		<logic:notEmpty name="EconomicValueForm" property="operation">
		<logic:equal property="operation" value="createUpdate" name="EconomicValueForm">
			<div class="edit_out align_center" style="width:800px;">
			<div class="edit align_center" style="width: 800px;">
	
			<table style="width: 800px;" class="no_border">
				<tr>
					<td class="text_blue_bold align_left" style="width: 20%"><bean:message
						key="economicIndexDef.label.code" /></td>
					<td class="text_blue_bold align_left" style="width: 20%"><bean:message
						key="costStructure.item.label.name" /></td>
					<td class="text_blue_bold align_left" style="width: 20%"><bean:message
						key="economicValue.label.tableHeader.currency" /></td>
					<%-- Modo Creacion --%>
					<logic:equal  property="section" value="new" name="EconomicValueForm">
						<td class="text_blue_bold align_left" style="width: 20%"><bean:message
							key="economicValue.label.tableHeader.valor" /></td>
						<td class="text_blue_bold align_left" style="width: 20%"><bean:message
							key="economicValue.label.tableHeader.tipoEcoV" /></td>
					</logic:equal>
					<%-- Modo Edicion--%>
					<td class="text_blue_bold align_left" style="width: 20%"><bean:message
							key="economicValue.label.tableHeader.variacion" /></td>
					<logic:equal  property="section" value="edit" name="EconomicValueForm">
						<td class="text_blue_bold align_left" style="width: 20%"><bean:message
							key="economicValue.label.tableHeader.valA" /></td>
					</logic:equal>
					<td class="text_blue_bold align_left" style="width: 20%"><bean:message
							key="economicValue.label.tableHeader.valorEstimado" /></td>
							
					<td class="text_blue_bold align_left" style="width: 20%"><bean:message
					key="economicSource" /></td>
					
						

	
					<td class="text_blue_bold align_left" style="width: 20%"><bean:message
						key="economicValues.label.tableHeader.efectiveDate" /></td>
					<td class="text_blue_bold align_rigth" style="width: 30%"><bean:message
						key="economicValue.label.tableHeader.actions" /></td>
				</tr>
				<tr>
					<td width="181"><bean:write name="EconomicValueForm"
						property="codeEcon" /></td>
					<td width="181"><bean:write name="EconomicValueForm"
						property="descEcon" /></td>
					<td class="align_left"><html:select property="currEcon">
						<html:option value="-1">
							<bean:message key="label.selectOption" />
						</html:option>
						<html:options collection="economicMeasure"
							property="eesm01CurrencyCodeC" labelProperty="eesm01CurrencyCodeC" />
					</html:select></td>
					<logic:equal  property="section" value="new" name="EconomicValueForm">
						<td class="align_left"><html:text property="valEco"
							maxlength="8" size="8" /></td>
						<td>
						<html:select property="typeCodeEco">
							<html:option value="-1">
								<bean:message key="label.selectOption" />
							</html:option>
						<html:options collection="economicsTypes" property="value"
						labelProperty="label" />
						</html:select></td>
					</logic:equal>
					<td class="align_left"><html:text property="porcEco"
							maxlength="5" size="6" /></td>
					<logic:equal  property="section" value="edit" name="EconomicValueForm">
						<td class="align_left">
						<html:text property="valEco"
						maxlength="10" size="10" />
						</td>
					</logic:equal>
						<td class="align_left">
							<html:select property="ecoStimateF">
							<html:option value="-1">
								<bean:message key="label.selectOption" />
							</html:option>
							<html:options collection="economicsEstimate" property="value"
							labelProperty="label" />
							</html:select>
						</td>
					<td class="align_left"><bean:write name="EconomicValueForm"
						property="sourEco" /></td>
	
					<td class="align_left"><html:text property="efecEco"
						maxlength="10" size="10" /></td>
					<td><html:image property="" onclick="createUpdateEconomic();"
						page="/images/save.gif" style="width:20px" />&nbsp; <html:image
						property="" onclick="cancelEconomic();" page="/images/delete.gif"
						style="width:20px" />&nbsp;</td>
				</tr>
			</table>
	
	
			</div>
			</div>
		</logic:equal>
	</logic:notEmpty>
	<br />

	<table class="no_border" style="width: 800px;">
		<tr>
			<td height="120">
				<ft:saveActivePageNumber />
				<display-el:table class="table1" style="width: 800px;"
				cellpadding="5" uid="economicValues" pagesize="12"
				name="sessionScope.EconomicValueForm.economicValues"
				excludedParams="*" requestURI="EconomicValueActionPaginate.do">
				<display-el:column title="${codeTitle}"
					property="economicValueActual.teese01Economic.eese01EconNumberK" style="width: 25%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right" />
				<display-el:column title="${descriptionTitle}"
					property="economicValueActual.teese01Economic.eese01EconNameN" style="width: 25%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right" />
				<display-el:column title="${unidadMonedaTitle}"
					property="economicValueActual.eese03CurrencyCodeC.eesm01CurrencyCodeC"
					style="width: 25%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right" />
					<display-el:column title="${valA}"
						property="economicValueActual.eese03EcvalueAmountA" style="width: 25%;"
						class="cell1 text_bold border1_right border1_top align_left"
						headerClass="header border_right" >
					</display-el:column>
					<display-el:column title="${porcVariacion}"
						style="width: 25%;"
						property="economicValueActual.eese03EcvalueVariaPercentP"
						class="cell1 text_bold border1_right border1_top align_left"
						headerClass="header border_right">
					</display-el:column>
					
					<!-- Valor Real o estimado -->
					<display-el:column title="${poriorVE}"
						style="width: 25%;"
						class="cell1 text_bold border1_right border1_top align_left"
						headerClass="header border_right" >
						<logic:notEmpty name="economicValues" property="economicValueActual.eese03EcvalueEstimateFlagF">
							<logic:equal property="economicValueActual.eese03EcvalueEstimateFlagF" value="0" name="economicValues">
							<bean:message key="label.no" />
							</logic:equal>
							<logic:equal property="economicValueActual.eese03EcvalueEstimateFlagF" value="1" name="economicValues">
							<bean:message key="label.yes" />
							</logic:equal>
						</logic:notEmpty>
					</display-el:column>
					<display-el:column title="${poriorV}"
						property="economicValuePasado.eese03EcvalueAmountA" style="width: 25%;"
						class="cell1 text_bold border1_right border1_top align_left"
						headerClass="header border_right" >
					</display-el:column>
					
					<%-- VALIDAR QUE LAS FECHAS NO OCUPEN EL DECORATOR --%>
					
					<display-el:column title="${poriorD}"
					property="economicValueActual.eese03EcvalueEffectivDateY"
					decorator="ar.com.ford.it.fullEconomics.view.displaytag.DateDecorator"
					style="width: 25%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right"/>

					
					<display-el:column title="${sourceTitle}"
						property="economicValueActual.teese01Economic.eese01EconsourceNumberR.eese02EconsourceNameN"
						style="width: 25%;"
						class="cell1 text_bold border1_right border1_top align_left"
						headerClass="header border_right" />

					<display-el:column title="${proposalRegistration}"
						style="width: 25%;"
						decorator="ar.com.ford.it.fullEconomics.view.displaytag.CostStructureItemColumnDecorator"
						class="cell1 text_bold border1_right border1_top align_left"
						headerClass="header border_right">
						<logic:empty name="economicValues" property="economicValueActual.eese03CreateUserC">
							<html:submit
								property="editMapped(${economicValues_rowNum})"
								styleClass="button" onclick="newEconomicValue();">
								<bean:message key="label.register" />
							</html:submit>
						</logic:empty>
						<logic:notEmpty name="economicValues" property="economicValueActual.eese03LastUserUpdtC">
							${economicValues.economicValueActual.eese03LastUserUpdtC}<br />${economicValues.economicValueActual.eese03LastUpdtS}
						</logic:notEmpty>
					</display-el:column>

					<display-el:column title="${approvalTitle}" style="width: 25%;"
						decorator="ar.com.ford.it.fullEconomics.view.displaytag.CostStructureItemColumnDecorator"
						class="cell1 text_bold border1_right border1_top align_left"
						headerClass="header border_right">
						<logic:notEmpty name="economicValues" property="economicValueActual.eese03CreateUserC">
							<logic:empty name="economicValues" property="economicValueActual.eese03EcvalueaApprovalUserC">
								<html:submit
									property="editMapped(${economicValues_rowNum})"
									styleClass="button" onclick="approveEconomicValueFromList();">
									<bean:message key="label.approve" />
								</html:submit>
							</logic:empty>
						</logic:notEmpty>
						<logic:notEmpty name="economicValues"
							property="economicValueActual.eese03EcvalueaApprovalUserC">
							${economicValues.economicValueActual.eese03EcvalueaApprovalUserC}<br />${economicValues.economicValueActual.eese03EcvalueApprovalS}
						</logic:notEmpty>
					</display-el:column>
					
					<display-el:column title="${actionsTitle}" style="width: 25%;"
						class="cell1 text_bold border1_right border1_top align_left"
						headerClass="header border_right">
					<logic:notEmpty name="economicValues" property="economicValueActual.eese03CreateUserC">
						<html:image property=""
							onclick="editEconomicValue(${economicValues_rowNum});" page="/images/edit.gif"
							style="width:20px" alt="Editar"/>&nbsp;
						<html:image property=""
							onclick="deleteEconomicValue(${economicValues_rowNum});" page="/images/erase.gif"
							style="width:20px" alt="Eliminar"/>&nbsp;
						<html:image property=""
							onclick="RejectEconomicValue(${economicValues_rowNum});" page="/images/icon_workflow_reject.gif"
							style="width:15px" alt="Rechazar"/>&nbsp;
					</logic:notEmpty>
					</display-el:column>
				
			</display-el:table>
			</td>
		</tr>
	</table>
</html:form>
